<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<html>
  <head>
    <title>${appname}</title>
	<%@include file="../meta.jsp"%>
	<script src="${ctx}/includes/jquery.js" type="text/javascript"></script>
	<script src="${ctx}/includes/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript" src="${ctx}/js/lhgdialog/lhgdialog.min.js"></script>
	<script src="${ctx}/includes/jquery.form.js" type="text/javascript"></script>
	<%-- 
	<script src="${ctx}/includes/formValidator.js" type="text/javascript"></script>
	<link type="text/css" rel="stylesheet" href="${ctx}/includes/style/validator.css"></link>
	--%>
	
	<script type="text/javascript">
		$(function(){
			$("#task_auth_form").validate({
				errorPlacement: function(error, element){
		            $(element).next('.field_notice').hide();
		            $(element).after(error);
		       },
			   success: function(label){   
			       label.addClass('right').text('OK!');
			   },
			   rules:   
			   {
			    	authname : {required : true}
			   },   
			   message:{
			    	authname : {required : '请输入授权人'}
			   }
			});    
		});
	</script>
  </head>
  
  <body>
    <div class="Teg_body">
    	<%@include file="../header.jsp"%>
    	
    	<div class="Teg_content">
    		<div class="content_left i-pane" id="zhd_LeftPane" paneid="LeftPane">
    			<div class="m-second-menu-title">
	    			<span class="Head">用户设置</span>
    			</div>
    			<div class="m-second-menu-ct ZHDAlignleft">
	    			<div class="accordion-3-container">
	    				<ul class="accordion-3">
	    					<li><div class="level-first"><a href="${ctx}/user/setting.do">用户信息设置</a></div></li>
	    					<li class="active"><div class="level-first"><a href="${ctx}/taskAuth/auth.do">任务处理授权</a></div></li>
	    				</ul>
	    			</div>
    			</div>
    			
    			<%@include file="../leftmenu.jsp"%>
    		</div>
    		<div class="content_right">
    			<div class="second_breadcrumb">
    				<span class="current_position">您的当前位置：<a href="${ctx}">首页</a>></span><span><a href="${ctx}/taskAuth/auth.do" class="SkinObject">任务处理授权</a></span>
    			</div>
    			<div class="content_ct i-pane" id="zhd_ContentPane" style="margin-top: 5px;">
    				<s:form action="/taskAuth/update.do" method="post" id="task_auth_form">
    				<s:token/>
    				<table class="form-table">
    					<tr>
							<th>
								<span class="note_red">*</span>被授权人：
							</th>
							<td>
								<s:textfield name="authname" title="请输入授权人" cssClass="form-txtinput" id="zrr" maxlength="20" readonly="true"/>
								<s:hidden name="authid" id="zrrbh"/>
							</td>
						</tr>
					</table>
					<div class="win-btn-panel">
						<c:if test="${authid == null}">
						<input class="btn-short" type="button" name="subbtn" value="授权" onclick="updateTaskAuth()" title="点击提交授权设置">
						</c:if>
						<c:if test="${authid != null}">
						<input class="btn-short" type="button" name="subbtn" value="授权回收" onclick="authRecovery()" title="点击提交授权回收">
						</c:if>
					</div>
					
    				</s:form>
    			</div>
    		</div>
    		<div class="clear"></div>
    	</div>
    	<%@include file="../bottom.jsp"%>
    </div>
  </body>
</html>
<script type="text/javascript">
function updateTaskAuth(){
	var v = $("#task_auth_form").valid();
	if(v){
		$('#task_auth_form').ajaxSubmit(resultHandler);
	}
}
function authRecovery(){
	window.location.href="${ctx}/taskAuth/authRecovery.do";
}
function resultHandler(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}
	else{
		alert(message);
		location.replace("${ctx}/taskAuth/auth.do?timsStamp=" + new Date().getTime());
	}
}
$('#zrr').click(function(){
	$.dialog({
	  	id:'abc', 
	  	title:'选择人员', 
	  	content: 'url:${ctx}/pub/userselect.jsp?timestamp='+new Date().getTime(), 
	  	max:false,
	  	min:false,
	  	width:600, 
	  	height:450,
	  	ok: function(){ 
	       	var m = abc.selectOnlyUser();
	        return m; 
	    }, 
	    cancelVal: '关闭', 
	    cancel: true
  	});
});
</script>